﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ZP.Web.Admin.User.Default" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <script type="text/javascript" src="../Kwan.Base.js"></script>
    <script type="text/javascript" src="Kwan.User.js"></script>
    <form id="Form2" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Gray" DirectMethodNamespace="User" />

        <ext:Store runat="server" ID="RoleDS" OnRefreshData="RefreshRoleDS">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="EntityID" />
                        <ext:RecordField Name="NameCN" />
                        <ext:RecordField Name="NameEN" />
                        <ext:RecordField Name="Memo" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>

        <ext:Store ID="Store1" runat="server" OnRefreshData="RefreshDS" RemoteSort="True">
            <Proxy>
                <ext:PageProxy />
            </Proxy>
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="EntityID" />
						<ext:RecordField Name="Answer" />
                        <%--<ext:RecordField Name="CreatedDate" />--%>
						<ext:RecordField Name="Email" />
						<ext:RecordField Name="Logo" />
                        <ext:RecordField Name="LoginCount" />
						<ext:RecordField Name="Password" />
						<ext:RecordField Name="Question" />
						<ext:RecordField Name="ResumeID" />
						<ext:RecordField Name="RoleID" />
						<ext:RecordField Name="RoleNameCN" />
                        <ext:RecordField Name="RoleNameEN" />
                        <ext:RecordField Name="RoleMemo" />
						<ext:RecordField Name="Scale" />
						<ext:RecordField Name="UserName" />                    
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <AutoLoadParams>
                <ext:Parameter Name="start" Value="0" Mode="Raw" />
                <ext:Parameter Name="limit" Value="15" Mode="Raw"/>
            </AutoLoadParams>
            <SortInfo Field="EntityID" Direction="DESC" />
        </ext:Store>
        <ext:Viewport runat="server" Layout="Fit">
            <Items>
        <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" Title="ExtGridTitle" AutoExpandColumn="UserName" Header="False" Frame="true" Height="500">
            <ColumnModel runat="server">
			    <Columns>
                    <ext:RowNumbererColumn />
					<ext:Column Header="用户名" DataIndex="UserName" Width="80" />
                    <ext:Column Header="角色" DataIndex="RoleNameCN" Width="80" />
                    <ext:Column Header="代码" DataIndex="RoleNameEN" Width="100" />
                    <ext:Column Header="角色备注" DataIndex="RoleMemo" Width="120" />
					<ext:Column Header="邮箱" DataIndex="Email" Width="150" />
                    <ext:Column Header="登陆次数" DataIndex="LoginCount" Width="80" />
                    <ext:CommandColumn Header="显示" DataIndex="Scale" Width="40">
                        <Commands>
                            <ext:GridCommand CommandName="Scale" />
                        </Commands>
                        <PrepareToolbar Fn="Kwan.prepareInt" />
                    </ext:CommandColumn>
			    </Columns>
            </ColumnModel>
            <TopBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Hidden ID="txtFilter" runat="server" AutoDataBind="true">
                            <Listeners>
                                <Change Handler="Store1.reload();" Delay="30" />
                            </Listeners>
                        </ext:Hidden>
                        <ext:TriggerField ID="txtSearch" runat="server" EmptyText=" 搜索用户.." EnableKeyEvents="true">
                            <Listeners>
                                <KeyDown Handler="if(!Ext.isEmpty(this.getValue())) { this.triggers[0].show();}else{this.triggers[0].hide();}" />
                                <TriggerClick Handler="if (index == 1) { Store1.reload(); } if(index == 0) { #{txtSearch}.reset(); #{txtFilter}.setValue(''); this.triggers[0].hide(); }" />
                            </Listeners>
                            <Triggers>
                                <ext:FieldTrigger Icon="Clear" HideTrigger="true" Qtip="清空" />
                                <ext:FieldTrigger Icon="Search" Qtip="搜索"/>
                            </Triggers>
                        </ext:TriggerField>
                        <ext:ToolbarFill runat="server" />
                        <ext:Button ID="BtnAddInfo" runat="server" Text="添加" Icon="Add">
                            <DirectEvents>
                                <Click OnEvent="BtnAddInfo_Click" />
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button ID="BtnDeleteInfo" runat="server" Text="批量删除" Icon="Delete">
                            <Listeners>
                                <Click Handler="Kwan.CheckDelete(#{GridPanel1}.getRowsValues({selectedOnly:true}));" />
                            </Listeners>
                        </ext:Button>
                        <ext:ToolbarSeparator runat="server" />
                        <ext:Button ID="BtnChangeScale" runat="server" Text="级别" Icon="ArrowSwitchBlueGreen">
                            <Menu>
                                <ext:Menu ID="Menu1" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="Scale_0" runat="server" Text="禁用" Icon="BulletCross" />
                                        <ext:MenuItem ID="Scale_1" runat="server" Text="免费" Icon="BulletTick" />
                                        <ext:MenuItem ID="Scale_2" runat="server" Text="VIP" Icon="Ruby" />
                                    </Items>
                                    <Listeners>
                                        <ItemClick Handler="User.ChangeState(Ext.encode(#{GridPanel1}.getRowsValues({selectedOnly:true})),menuItem.id);" />
                                    </Listeners>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <SelectionModel>
               <ext:CheckboxSelectionModel runat="server" />                   
            </SelectionModel>
            <LoadMask ShowMask="true" />
            <SaveMask ShowMask="true" />
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="15">
                    <Items>
                        <ext:Label runat="server" Text="每页显示:" />
                        <ext:ToolbarSpacer runat="server" Width="10" />
                        <ext:ComboBox Editable="false" runat="server" Width="80">
                            <Items>
                                <ext:ListItem Text="15" />
                                <ext:ListItem Text="20" />
                                <ext:ListItem Text="50" />
                                <ext:ListItem Text="100" />
                            </Items>
                            <SelectedItem Value="15" />
                            <Listeners>
                                <Select Handler="#{PagingToolBar1}.pageSize = parseInt(this.getValue());#{PagingToolBar1}.doLoad();" />
                            </Listeners>
                        </ext:ComboBox>
                    </Items>
                </ext:PagingToolbar>
            </BottomBar>
            <Listeners>
                <Command Handler="Kwan.CellCommand(this, record, command, rowIndex)" />
                <RowDblClick Handler="Kwan.CellCommand(this, this.store.getAt(rowIndex), 'Edit', rowIndex)" />
            </Listeners>        
        </ext:GridPanel>
        </Items>
        </ext:Viewport>
        <ext:Window ID="EditWindow" runat="server" Icon="Group" Title="编辑数据" Width="500" Height="260" AutoShow="false" Modal="true" Collapsible="true" Maximizable="true" Hidden="true" Layout="Fit" LabelWidth="70" AnimateTarget="GridPanel1">
            <Items>
                <ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Border="false" DeferredRender="false">
                    <Items>
                        <ext:FormPanel ID="EditForm" MonitorValid="true" runat="server" Title="基本信息" Icon="ChartOrganisation" Padding="5" Layout="Form" LabelAlign="Right" LabelWidth="70" MonitorResize="true">
                            <Items>
                                <ext:Hidden ID="txtID" runat="server" />
								<ext:TextField ID="txtUserName" FieldLabel="用户名" AnchorHorizontal="98%" AllowBlank="false" runat="server" />
                                <ext:DropDownField ID="txtRoleID" runat="server" FieldLabel="角色" Editable="false" Width="300" TriggerIcon="Search" Mode="ValueText" AllowBlank="false">
                                    <Component>
                                        <ext:TreePanel ID="TreePanel1" runat="server" Icon="Accept" Height="300" AutoScroll="true" RootVisible="false">
                                        <Root>
                                            <ext:AsyncTreeNode Text="Examples" NodeID="root" Expanded="true" Checked="False" />
                                        </Root>
                                        <Loader>
                                            <ext:PageTreeLoader RequestMethod="POST" OnNodeLoad="GetExamplesNodes" PreloadChildren="true" />
                                        </Loader>
                                        <SelectionSubmitConfig Encode="true" />
                                        <Listeners>
                                            <Click Handler="this.dropDownField.setValue(node.id,node.attributes.text,true);" />
                                        </Listeners>
                                    </ext:TreePanel>
                                    </Component>
                                    <Listeners>
                                        <Expand Handler="this.component.getRootNode().expand(true);" Single="true" Delay="10" />
                                    </Listeners>
                                </ext:DropDownField>
								<ext:TextField ID="txtEmail" FieldLabel="邮箱" AnchorHorizontal="98%" AllowBlank="false" runat="server" />
                                <ext:TextField ID="txtPassword" InputType="Password" FieldLabel="密码" AnchorHorizontal="98%" AllowBlank="false" runat="server" />
                                <ext:FileUploadField ID="txtLogo" runat="server" EmptyText="选择图片" FieldLabel="头像" AnchorHorizontal="40%" ButtonText="" Icon="ImageAdd" />
                                <ext:ComboBox ID="txtScale" Editable="false" FieldLabel="级别" EmptyText="请选择..." AnchorHorizontal="30%" AllowBlank="false" runat="server">
                                    <Items>
                                        <ext:ListItem Text="禁用" Value="0" />
                                        <ext:ListItem Text="免费" Value="1" />
                                        <ext:ListItem Text="VIP" Value="2" />
                                    </Items>
                                    <SelectedItem Value="1" />
                                </ext:ComboBox>
                            </Items>
                            <Listeners>
                                <ClientValidation Handler="#{SaveButton}.setDisabled(!valid);" />
                            </Listeners>
                        </ext:FormPanel>
                    </Items>
                </ext:TabPanel>
            </Items>
            <Buttons>
                <ext:Button ID="SaveButton" runat="server" Text="保存" Icon="Disk">
                    <DirectEvents>
                        <Click OnEvent="SaveEditWindow" Failure="Ext.MessageBox.alert('系统提示', response.statusText);">
                            <EventMask Target="CustomTarget" CustomTarget="={#{EditWindow}.body}" ShowMask="True" />
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="CancelButton" runat="server" Text="返回" Icon="Cancel">
                    <Listeners>
                        <Click Handler="#{EditWindow}.hide();" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:Window>
    </form>
</body>
</html>